//
//  KINGUser.swift
//  肉荣微博
//
//  Created by king on 15/8/2.
//  Copyright © 2015年 king. All rights reserved.
//

import UIKit

class KINGUser: NSObject {
    /// 用户代号
    var id:Int = 0
    /// 好友显示名称
    var name: String?
    /// 用户头像地址 50*50
    var profile_image_url: String? {//即使不使用也不能用private进行修饰，字典转模型的时候不能获取值
        didSet {
            imageUrl = NSURL(string: profile_image_url!)
        }
    }
    /// 用户头像URL
    var imageUrl:NSURL?
    /// 用户认证类型，-1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
    var verified_type: Int = -1 {
        didSet{
            switch verified_type {
            case 0 :
                verifiedImage = UIImage(named: "avatar_vip")
            case 2, 3, 5 :
                verifiedImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedImage = UIImage(named: "avatar_grassroot")
            default:
                verifiedImage = nil
            }
        }
    }
    /// 认证头像
    var verifiedImage:UIImage?
    /// 会员等级
    var mbrank: Int = -1 {
        didSet{
            mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
        }
    }
    /// 会员图片
    var mbrankImage:UIImage?
    
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {    }
    
    override var description: String {
        let keys = ["name", "profile_image_url"]
        return "\(dictionaryWithValuesForKeys(keys))"
    }
}
